(function () {

  /**
   * mode 1 新增, 2 编辑
   */
  function getFormBody(mode = '1')
  {
    return [
      {
        "type": "text",
        "size": "lg",
        "name": "name",
        "label": "权益名称",
        "required": true
      },
      {
        "type": "divider"
      },
      {
        "type": "input-number",
        "label": "次数",
        "size": "lg",
        "name": "numbers",
        "validateOnChange": true,
        "validations": {
          "isInt": true,
          "minimum": 1,
        },
      },
      {
        "type": "divider"
      },
    ];
  }

  let staticFormBody = [
    // 远程数据
    {
      "type": "timeline",
      "source": {
        "method": "get",
        "url": "/b/rcl/timeline?third_id=${id}"
      }
    },
  ];

  return {
    "type": "page",
    "initApi": "/b/permits/init",
    "title": "消息列表",
    "body": {
      "type": "crud",
      "className": "break-all",
      "hideQuickSaveBtn": true,
      "api": "get:/b/notice/index",
      "quickSaveApi": "post:/b/notice/batch",
      "quickSaveItemApi": "post:/b/notice/item?id=$id",
      // "itemCheckableOn": "this.is_super !== 1 && this.leader_count === 0",
      "perPage": 10,
      "keepItemSelectionOnPageChange": true,
      "maxKeepItemSelectionLength": 20,
      "pageField": "page",
      "perPageField": "page_size",
      "labelTpl": "${name}",
      "syncLocation": false,
      "filter": {
        "title": "条件搜索",
        "submitText": "搜索",
        "controls": [
          {
            "label": "消息内容：",
            "type": "text",
            "size": "sm",
            "name": "content",
            "placeholder": "请输入"
          },
          {
            "label": "状态",
            "type": "select",
            "size": "sm",
            "name": "type",
            "searchable": true,
            "placeholder": "请选择",
            "options": [
              {
                "label": "已处理",
                "value": 3
              },
              {
                "label": "未处理",
                "value": 102
              },
              {
                "label": "已逾期",
                "value": 103
              },
            ]
          },
          {
            "type": "datetime-range",
            "name": "createtime",
            "label": "创建时间："
          }
        ],
        "actions": [
          {
            "type": "button",
            "actionType": "clear",
            "label": "重置"
          },
          {
            "type": "button",
            "actionType": "submit",
            "label": "搜索",
            "level": "primary",
          }
        ]
      },
      "bulkActions": [
        // {
        //   "label": "批量删除",
        //   "visibleOn": "isInArray(this.front_end, 'admin_list_delete')",
        //   "level": "danger",
        //   "actionType": "ajax",
        //   "api": "post:/b/admin/del/${ids|raw}",
        //   "confirmText": "确定要批量删除?"
        // }
      ],
      "filterTogglable": true,
      "headerToolbar": [
        "filter-toggler",
        "bulkActions",
        {
          "type": "columns-toggler",
          "align": "right"
        },
        {
          "type": "pagination",
          "align": "right"
        }
      ],
      "footerToolbar": [
        "statistics",
        "switch-per-page",
        "pagination"
      ],
      "columns": [
        {
          "name": "id",
          "label": "ID",
          "hidden": true,
          "sortable": true,
          "type": "text",
          "toggled": true
        },
        {
          "name": "content",
          "label": "消息内容",
          "sortable": false,
          "searchable": false,
          "type": "text",
          "toggled": true,
        },
        {
          "name": "type_map",
          "label": "状态",
          "sortable": false,
          "searchable": false,
          "type": "text",
          "toggled": true,
        },
        {
          "name": "created_at",
          "label": "创建时间",
          "type": "text",
          "sortable": false,
          "toggled": true
        },
        {
          "type": "operation",
          "label": "操作",
          "buttons": [
            {
              "label": "查看",
              "visibleOn": "this.relation_type === 1 || this.relation_type === 2 || this.type === 3",
              "type": "button",
              // "level": "info",
              "actionType": "link",
              "link": "${link}"
            },
            {
              "label": "查看",
              "visibleOn": "this.relation_type !== 1 && this.relation_type !== 2 && this.type !== 3",
              "type": "button",
              "actionType": "ajax",
              "api": "/b/notice/complete?id=${id}",
              "redirect": "${link|raw}"
            }
          ],
          "toggled": true
        }
      ]
    }
  };
})();